local guishou = fk.CreateSkill {
  name = "ls__guishou",
}


Fk:loadTranslationTable{
  ["ls__guishou"] = "鬼狩",
  [":ls__guishou"] = "回合开始时，你可选择一名其他角色，你弃置其每个牌数不小于你的区域各一张牌，然后你摸X张牌（X为其有牌的区域数）。",
  ["#ls__guishou-target"] = "鬼狩：选择一名其他角色，你弃置其每个牌数不小于你的区域各一张牌",

  ["$ls__guishou1"] = "百骑劫魏营，功震天下英。",
  ["$ls__guishou2"] = "劫敌营寨，以破其胆。",
}

local U = require "packages/utility/utility"

guishou:addEffect(fk.TurnStart, {
  anim_type = "control",
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 1,
      targets = table.filter(room:getOtherPlayers(player), function (p) return not p:isAllNude() end),
      skill_name = guishou.name,
      prompt = "#ls__guishou-target",
      cancelable = true,
    })
    if #to > 0 then
      event:setCostData(self, {tos = to})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    local areas = {"h", "e", "j"}
    if to:getHandcardNum() < player:getHandcardNum() then table.removeOne(areas, "h") end
    if #to:getCardIds("e") < #player:getCardIds("e") then table.removeOne(areas, "e") end
    if #to:getCardIds("j") < #player:getCardIds("j") then table.removeOne(areas, "j") end
    if #areas == 0 then return end
    local cards = U.askforCardsChosenFromAreas(player, to, table.concat(areas), guishou.name, "", {}, false)
    room:throwCard(cards, guishou.name, to, player)
    local n = 0
    if not to:isKongcheng() then n = n + 1 end
    if #to:getCardIds("e") > 0 then n = n + 1 end
    if #to:getCardIds("j") > 0 then n = n + 1 end
    player:drawCards(n, guishou.name)
  end,
})


return guishou